<template>
  <div class="about">
    <!-- <h1>个人中心</h1> -->
    <!-- <div>{{ LoginUser }}</div> -->
    <div class="name">
      <div class="img">
        <img :src="LoginUser.avatar" alt="头像" />
      </div>
      <div class="user">
        <span class="usern">{{ LoginUser.nickname }}</span>
        <div class="userh"><van-icon name="star" />黄金会员</div>
        <br />
        <span class="useri">ID:{{ LoginUser.uid }}</span>
      </div>
      <router-link class="bj" to="/edit">
        <van-icon name="setting-o" />
      </router-link>
    </div>
    <div class="money">
      <ul class="flex">
        <li>
          <div>我的余额</div>
          <h1>{{ LoginUser.now_money }}</h1>
        </li>
        <li>
          <div>当前佣金</div>
          <h1>0.00</h1>
        </li>
        <li>
          <div>优惠券</div>
          <h1>0</h1>
        </li>
      </ul>
    </div>
    <div class="order">
      <div>
        <h1>我的订单</h1>
        <router-link to="/">全部订单></router-link>
      </div>
      <ul>
        <li @click="hello">
          <van-icon name="pending-payment" />
          <h1>待付款</h1>
        </li>
        <li @click="hello">
          <van-icon name="logistics" />
          <h1>待发货</h1>
        </li>
        <li @click="hello">
          <van-icon name="send-gift-o" />
          <h1>待收货</h1>
        </li>
        <li @click="hello">
          <van-icon name="chat-o" />
          <h1>待评价</h1>
        </li>
        <li @click="hello">
          <van-icon name="after-sale" />
          <h1>售后/退款</h1>
        </li>
      </ul>
    </div>
    <div class="service">
      <div>
        <h1>我的服务</h1>
      </div>
      <ul>
        <li>
          <van-icon name="contact" />
          <h1>会员中心</h1>
        </li>
        <li>
          <van-icon name="point-gift-o" />
          <h1>砍价记录</h1>
        </li>
        <li>
          <van-icon name="friends-o" />
          <h1>我的推广</h1>
        </li>
        <li>
          <van-icon name="gold-coin-o" />
          <h1>我的余额</h1>
        </li>
        <li @click="$router.push('/address')">
          <van-icon name="location-o" />
          <h1>地址信息</h1>
        </li>
        <li>
          <van-icon name="star-o" />
          <h1>我的收藏</h1>
        </li>
        <li>
          <van-icon name="coupon-o" />
          <h1>优惠券</h1>
        </li>
        <li>
          <van-icon name="friends-o" />
          <h1>联系人</h1>
        </li>
      </ul>
    </div>
    <!-- <div>昵称：{{LoginUser.nickname}} 手机号：{{LoginUser.phone}}</div> -->
    <!-- <router-link to="/edit">编辑收货地址</router-link> -->
    <br />
    <button @click="logout">退出登录</button>
  </div>
</template>
<script>
import { mapMutations, mapGetters } from "vuex";
import { Dialog, Toast } from "vant";
export default {
  name: "User",
  data() {
    return {};
  },
  created() {
    console.log(this.LoginUser);
  },
  methods: {
    ...mapMutations(["LoginOut"]),
    logout() {
      this.LoginOut();
      Dialog({
        title: "退出登录",
        message: "退出成功！",
      }).then(() => {
        this.$router.push("/");
      });
    },
    hello() {
      if (this.addBuy.length==0) {
        Toast("请先去购买商品");
      }else{
        this.$router.push("/buy");
      }
    },
  },
  computed: {
    ...mapGetters(["LoginUser"]),
    addBuy() {
      return this.$store.state.addBuy;
    },
  },
};
</script>
<style scoped lang="less">
.about {
  position: absolute;
  background: #f5f5f5;
  z-index: -2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  font-size: 16px;
}
.name {
  width: 100%;
  background: var(--cy-Color);
  color: white;
  display: flex;
  position: relative;
  .img {
    width: 70px;
    height: 70px;
    margin: 10px;
    background: white;
    border-radius: 50%;
    border: 2px white solid;
    img {
      width: 100%;
      height: 100%;
      border-radius: 50%;
    }
  }
  .user {
    margin: 30px 10px 10px 10px;
    position: relative;
    .usern {
      font-size: 20px;
    }
    .userh {
      position: absolute;
      top: 0px;
      left: 25vw;
      width: 70px;
      font-size: 13px;
      padding: 5px;
      background: #0000003d;
      border-radius: 30px;
      i {
        color: #fff480;
      }
    }
    .useri {
      font-size: 14px;
      color: rgba(255, 255, 255, 0.5);
    }
  }
  a.bj {
    position: absolute;
    right: 25px;
    top: 25px;
    font-size: 30px;
    color: white;
    padding: 8px;
    width: 30px;
    height: 30px;
  }
}
.name:after {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.8rem;
  z-index: -1;
  content: "";
  height: 1rem;
  width: 100%;
  border-radius: 0 0 50% 50%;
  background-color: var(--cy-Color);
}
.money {
  width: 94vw;
  background: white;
  margin: 0 auto;
  border-radius: 5px;
  height: 10vh;
  ul {
    display: flex;
    text-align: center;
    padding: 10px 0px;
    justify-content: space-around;
    li {
      padding: 0px 6vw;
      line-height: 25px;
      &:nth-child(2) {
        border-left: 1px solid #99999945;
        border-right: 1px solid #99999945;
      }
      div {
        font-size: 14px;
        color: #999;
      }
      h1 {
        font-size: 16px;
      }
    }
  }
}
.order {
  width: 94vw;
  background: white;
  font-size: 16px;
  margin: 10px auto;
  padding-top: 10px;
  border-radius: 5px;
  div {
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    height: 20px;
    border-bottom: 3px dashed #f5f5f5;
    a {
      color: #999;
    }
  }
  ul {
    display: flex;
    justify-content: space-around;
    padding: 5px;
    li {
      width: 60px;
      padding: 5px;
      line-height: 25px;
      text-align: center;
      i {
        font-size: 35px;
        color: var(--cy-Color);
      }
      h1 {
        font-size: 12px;
        color: #999;
      }
    }
  }
}
.service {
  width: 94vw;
  background: white;
  margin: 7px auto;
  border-radius: 5px;
  padding: 5px 0px;
  font-size: 16px;
  div {
    padding: 5px 0px 5px 10px;
    height: 20px;
    border-bottom: 3px dashed #f5f5f5;
  }
  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    text-align: center;
    padding: 5px;
    li {
      width: 22%;
      padding: 5px;
      i {
        font-size: 25px;
        color: var(--cy-Color);
        padding: 10px;
      }
      h1 {
        font-size: 14px;
      }
    }
  }
}
button {
  width: 140px;
  background: white;
  border: none;
  border-radius: 30px;
  padding: 10px;
  margin: 5px 32%;
  position: absolute;
}
</style>